$(function () {
  var curentpage = 1
  //var sizePage = 100

  var url = location.href
  var str = url.split('=')[1]
  var str = decodeURI(str)
  console.log(str);
  $('.search_input').val(str)



  var obj = {
    pageSize: 100,
    page: curentpage,
    proName: str,
  }
  setTimeout(function () {

  })
  function render() {
    $.ajax({
      type: 'get',
      url: '/product/queryProduct',
      data: obj,
      dataType: 'json',
      // beforeSend: function () {
      //   delay(3)
      // },
      success: function (res) {
        console.log(res);
        setTimeout(function () {
          $('.search-porduct ul').html(template('tmp', res))
        }, 1000)


      }
    })
  }
  render()
  $('.search_btn').click(function () {
    if ($('.search_input').val() !== '') {
      var str = $('.search_input').val().trim()
      obj.proName = str
      render()
    }

  })
  //var id = ''
  $('.search-porduct ul').on('click','a',function() {
   var id = $(this).parent().data('id')
   console.log(id);
   
    location.href='product.html?id='+id
    
  })

})